local sugar = SUGAR_webber_the_trainer

---@type data_buff[]
local data = {
    -- 蛛灵之枢 - 共生加速
    {
        id = 'webbert_staff_arachnidnexus_skill_healaccel',
        onattachedfn = function (inst, target, id)
            if target then
                if target.components.locomotor then
                    target.components.locomotor:SetExternalSpeedMultiplier(inst,id,TUNING.MOD_WEBBER_THE_TRAINER.ITEMS.staff_arachnidnexus.skill_1.walkspeedmult)
                end
                SUGAR_webber_the_trainer:taskDoPeriodicForAWhile(target,'task_period_webbert_staff_arachnidnexus_skill_healaccel',TUNING.MOD_WEBBER_THE_TRAINER.ITEMS.staff_arachnidnexus.skill_1.heal_interval,nil,function ()
                    if target then
                        if target.components.health and not target.components.health:IsDead() and not target:HasTag('playerghost') then
                            target.components.health:DoDelta(TUNING.MOD_WEBBER_THE_TRAINER.ITEMS.staff_arachnidnexus.skill_1.heal)
                        end
                    end
                end,nil,0)
                local fx = SUGAR_webber_the_trainer:addEntRefer(target,'webbert_staff_arachnidnexus_skill_healaccel_fx',SpawnPrefab('particle_webbert_staff_healfx'),true)
                fx.entity:SetParent(target.entity)
            end
        end,
        ondetachedfn = function (inst, target, id)
            if target then
                if target.components.locomotor then
                    target.components.locomotor:RemoveExternalSpeedMultiplier(inst, id)
                end
                SUGAR_webber_the_trainer:taskCancel(target,'task_period_webbert_staff_arachnidnexus_skill_healaccel')
                SUGAR_webber_the_trainer:removeEntRefer(target,'webbert_staff_arachnidnexus_skill_healaccel_fx')
            end
        end,
        duration = TUNING.MOD_WEBBER_THE_TRAINER.ITEMS.staff_arachnidnexus.skill_1.duration,
        buff_string = STRINGS.MOD_WEBBER_THE_TRAINER.BUFFS.webbert_staff_arachnidnexus_skill_healaccel.buff_string,
    },
    -- 木屑面包 耐饿
    {
        id = 'webbert_bread_burnrate_buff',
        onattachedfn = function (inst, target, id)
            if target.components.hunger then
                target.components.hunger.burnratemodifiers:SetModifier(inst,TUNING.MOD_WEBBER_THE_TRAINER.ITEMS.webbert_bread.hungerrate,'webbert_bread_burnrate_buff')
            end
        end,
        ondetachedfn = function (inst, target, id)
            if target.components.hunger then
                target.components.hunger.burnratemodifiers:RemoveModifier(inst,'webbert_bread_burnrate_buff')
            end
        end,
        duration = TUNING.MOD_WEBBER_THE_TRAINER.ITEMS.webbert_bread.duration,
        buff_string = STRINGS.MOD_WEBBER_THE_TRAINER.BUFFS.webbert_bread_burnrate.buff_string,
    },
    -- 拉肚子
    {
        id = 'webbert_soul_buy_times_7_debuff',
        onattachedfn = function (inst, target, id)
            SUGAR_webber_the_trainer:taskDoPeriodicForAWhile(target,'task_period_webbert_soul_buy_times_7_debuff',TUNING.MOD_WEBBER_THE_TRAINER.webbert_soul.buy.buy_7_debuff_interval,TUNING.MOD_WEBBER_THE_TRAINER.webbert_soul.buy.buy_7_debuff_duration,function()
                if target.components.hunger then
                    target.components.hunger:DoDelta(-TUNING.MOD_WEBBER_THE_TRAINER.webbert_soul.buy.buy_7_debuff_reduce_hunger)
                end
                SpawnPrefab('poop').Transform:SetPosition(target:GetPosition():Get())
            end)
        end,
        ondetachedfn = function (inst, target, id)
            SUGAR_webber_the_trainer:taskCancel(target,'task_period_webbert_soul_buy_times_7_debuff')
        end,
        duration = TUNING.MOD_WEBBER_THE_TRAINER.webbert_soul.buy.buy_7_debuff_duration,
        buff_string = STRINGS.MOD_WEBBER_THE_TRAINER.BUFFS.webbert_soul_buy_times_7_debuff.buff_string,
        attached_string = STRINGS.MOD_WEBBER_THE_TRAINER.BUFFS.webbert_soul_buy_times_7_debuff.attached_string,
    },
    -- 料理: 蛛丝爆浆蛋 攻速加成
    {
        id = 'webbert_dish_silkglandegg_atkspeed_buff',
        onattachedfn = function (inst, target, id)
            if target.Modifier_common_atkspeedmodifier then
                target:Modifier_common_atkspeedmodifier(inst,TUNING.MOD_WEBBER_THE_TRAINER.ITEMS.webbert_dish_silkglandegg.buff_atkspeedadd,id)
            end
        end,
        ondetachedfn = function (inst, target, id)
            if target.RemoveModifier_common_atkspeedmodifier then
                target:RemoveModifier_common_atkspeedmodifier(inst,id)
            end
        end,
        duration = TUNING.MOD_WEBBER_THE_TRAINER.ITEMS.webbert_dish_silkglandegg.buff_duration,
        buff_string = STRINGS.MOD_WEBBER_THE_TRAINER.BUFFS.webbert_dish_silkglandegg_atkspeed_buff.buff_string,
        attached_string = STRINGS.MOD_WEBBER_THE_TRAINER.BUFFS.webbert_dish_silkglandegg_atkspeed_buff.attached_string,
        detached_string = STRINGS.MOD_WEBBER_THE_TRAINER.BUFFS.webbert_dish_silkglandegg_atkspeed_buff.detached_string,
    },
    -- 料理: 月光蛛网冻 移速加成
    {
        id = 'webbert_dish_mushroomsilkjelly_buff',
        onattachedfn = function (inst, target, id)
            if target.components.locomotor then
                target.components.locomotor:SetExternalSpeedMultiplier(inst, id, TUNING.MOD_WEBBER_THE_TRAINER.ITEMS.webbert_dish_mushroomsilkjelly.buff_walkspeedmult)
            end
        end,
        ondetachedfn = function (inst, target, id)
            if target.components.locomotor then
                target.components.locomotor:RemoveExternalSpeedMultiplier(inst, id)
            end
        end,
        duration = TUNING.MOD_WEBBER_THE_TRAINER.ITEMS.webbert_dish_mushroomsilkjelly.buff_duration,
        buff_string = STRINGS.MOD_WEBBER_THE_TRAINER.BUFFS.webbert_dish_mushroomsilkjelly_buff.buff_string,
        attached_string = STRINGS.MOD_WEBBER_THE_TRAINER.BUFFS.webbert_dish_mushroomsilkjelly_buff.attached_string,
        detached_string = STRINGS.MOD_WEBBER_THE_TRAINER.BUFFS.webbert_dish_mushroomsilkjelly_buff.detached_string,
    },
    -- 料理: 活力孢子羹 san,血契
    {
        id = 'webbert_dish_sporeglandsoup_buff',
        onattachedfn = function (inst, target, id)
            sugar:taskDoPeriodicForAWhile(target, 'taskperiod_'..id,1,nil,function ()
                if target and target.components.sanity then
                    target.components.sanity:DoDelta(TUNING.MOD_WEBBER_THE_TRAINER.ITEMS.webbert_dish_sporeglandsoup.buff_regensan,true)
                end
            end)
            if target.components.webbert_soul then
                target.components.webbert_soul:SetModifier(inst,TUNING.MOD_WEBBER_THE_TRAINER.ITEMS.webbert_dish_sporeglandsoup.buff_bloodpact_modifier,id)
            end
        end,
        ondetachedfn = function (inst, target, id)
            sugar:taskCancel(target,'taskperiod_'..id)
            if target.components.webbert_soul then
                target.components.webbert_soul:RemoveModifier(inst,id)
            end
        end,
        duration = TUNING.MOD_WEBBER_THE_TRAINER.ITEMS.webbert_dish_sporeglandsoup.buff_duration,
        buff_string = STRINGS.MOD_WEBBER_THE_TRAINER.BUFFS.webbert_dish_sporeglandsoup_buff.buff_string,
        -- attached_string = STRINGS.MOD_WEBBER_THE_TRAINER.BUFFS.webbert_dish_sporeglandsoup_buff.attached_string,
        -- detached_string = STRINGS.MOD_WEBBER_THE_TRAINER.BUFFS.webbert_dish_sporeglandsoup_buff.detached_string,
    },
    -- 料理: 龙脊焚劫烩 霸体
    {
        id = 'webbert_dish_dragoninfernostew_buff',
        onattachedfn = function (inst, target, id)
            target:AddStamp('superarmor')
        end,
        ondetachedfn = function (inst, target, id)
            target:RemoveStamp('superarmor')
        end,
        duration = TUNING.MOD_WEBBER_THE_TRAINER.ITEMS.webbert_dish_dragoninfernostew.buff_duration,
        buff_string = STRINGS.MOD_WEBBER_THE_TRAINER.BUFFS.webbert_dish_dragoninfernostew_buff.buff_string,
    },
    -- 料理: 轮回之心 死而复生
    {
        id = 'webbert_dish_respawnheart_buff',
        onattachedfn = function (inst, target, id)
            target:AddStamp('respawn_after_death')
        end,
        ondetachedfn = function (inst, target, id)
            -- 死亡后buff会移除, 所以这里根本不跑
        end,
        duration = 99*60,
        buff_string = STRINGS.MOD_WEBBER_THE_TRAINER.BUFFS.webbert_dish_respawnheart_buff.buff_string,
        paused = true,
    },
    -- 正义: 杏梨偷东西反噬
    {
        id = 'webbert_steal_by_xl_debuff',
        onattachedfn = function (inst, target, id)
            if target.components.locomotor then
                target.components.locomotor:SetExternalSpeedMultiplier(target,'webbert_steal_by_xl_debuff',.5)
            end
            sugar:taskDoPeriodicForAWhile(target,'taskperiod_webbert_steal_by_xl_debuff',10,nil,function ()
                if target and target:IsValid() and target.components.playerlightningtarget then
                    target.components.playerlightningtarget:DoStrike()
                    SpawnPrefab('lightning').Transform:SetPosition(target:GetPosition():Get())
                end
            end)
        end,
        ondetachedfn = function (inst, target, id)
            if target.components.locomotor then
                target.components.locomotor:RemoveExternalSpeedMultiplier(target,'webbert_steal_by_xl_debuff')
            end
            sugar:taskCancel(target,'taskperiod_webbert_steal_by_xl_debuff')
        end,
        duration = 60,
        buff_string = 'lan的神罚',
    }

}


return data